import minRequest from '@/config/minRequest.js'
const url = '/customer'
/**
 * 登录
 * @param {Object}  {code: string}
 * @param {Object}  {code: string,appId：string}新的
 * @return  返回一个Promise
 */
// export const login = (params) => minRequest.post('/open/applet/judgeBinding', params)
export const login = (params) => minRequest.post(url + '/open/applet/judgeBindingWithAppId', params)

// 根据返回 分析用户是 业务员 还是 客户
export const getCustomerPhoneNumberWithAppId = (params) => minRequest.post(url +
	'/applet/open/loginSalesmanTokenByPhone', params)

// 根据返回 分析用户是 业务员 还是 客户
export const loginSalesmanTokenByPhoneWithToken = (params) => minRequest.get(url +
	'/applet/open/loginSalesmanTokenByPhoneWithToken', params)

/**
 * 获取手机号
 // * @param {Object} {code:string,vi:string}
 * @param {Object} {code:string,vi:string,AppId:string}
 * @return 返回一个Promise
 */
// export const getphonenumber = (params) => minRequest.post('/applet/getUserPhoneNumber', params)
export const getphonenumber = (params) => minRequest.post(url + '/applet/getUserPhoneNumberWithAppId', params)

/**
 * 登录后获取用户信息
 * @param 
 */
export const getCustomerInfoByToken = () => minRequest.get(url + '/customer/getCustomerInfoByToken')

/**
 * 获取协议或者客服电话
 * @param 
 */
export const getProtocolByCode = (code) => minRequest.get(url + '/open/protocol/getProtocolByCode/' + code)
/**
 * 根据客户id修改客户的信息
 * @param {Object}  {avatar:string,nickName:string,id:string}
 */
export const updateCustomerByCustomerId = (params) => {
	return minRequest.post(url + '/customer/updateCustomerByCustomerId', params).then(res => {
		return res.data
	}).catch(error => {
		return error.msg
	})
}


// 配置视频模块是否显示
export const showVideo = (configKey) => minRequest.get(url + `/config/open/configKey/${configKey}`)
// 根据客户ID获取信息
export const getCustomerByIdNoToken = (id) => minRequest.get(url + `/customer/open/getCustomerByIdNoToken/${id}`)

export const customerAddress = (params, id) => minRequest.post(url + '/customerAddress/batchCreate', params)

// 根据客户ID
export const getCustomerAddress = (id) => minRequest.get(url + `/customerAddress/getCustomerAddress/${id}`)
// 根据客户ID
export const getCustomerAddressNoToken = (id) => minRequest.get(url + `/customerAddress/open/getCustomerAddressNoToken/${id}`)
export const objectFileUpdate = (params) => minRequest.post(url + '/objectFile/update', params)

export const updateCustomerManage = (params) => minRequest.post(url + '/CustomerManageFor/updateCustomerManage', params)

export const getCustomerManageInfo = (params) => minRequest.post(url + '/CustomerManageFor/open/getCustomerManageInfo', params)

export const getCustomerManageTagList = (params) => minRequest.post(url + '/CustomerManageFor/getCustomerManageTagList', params)

//成员分页查询
// export const teamCustomerPage = (params) => minRequest.post(url + '/teamRelationship/teamCustomerPage', params)
// export const teamRelationship = (params) => minRequest.get(url + '/teamRelationship/list', params)
export const teamRelationship = (params) => minRequest.post(url + '/customer/getGroupCustomerList', params)

//分页条件查询订单列表
export const teamOrder = (params) => minRequest.post(url + '/v103/order/getGroupCustomerPromoteOrder', params)
//获取分组业务员客户业绩统计
export const teamOrderInfo = (params) => minRequest.post(url + '/v103/order/getOrderPerformanceStatistics', params)

export const getByPhone = (params) => minRequest.post(url + '/health/token/getByPhone', params)

//邀请客户成为业务员，用户回填信息提交
export const getInviteToBeSalesman = (params) => minRequest.post(url + '/want_to_be_salesman/inviteToBeSalesman', params)